import PD from "../libs";
/**
 * 自定义导航栏相关
 * @returns statusBarHeight:状态栏高度，statusBarHeightPx:状态栏高度带单位（px）
 * @returns navHeight:自定义导航栏高度，navHeightPx:自定义导航栏高度带单位（px）
 * @returns customHeaderHeight:自定义头部高度，customHeaderHeightPx:自定义导航栏高度带单位（px）
 */
export function useCustomHeader () {
	const {statusBarHeight} = PD.UniHelp.getSystemInfo();
	const {height, top} = uni.getMenuButtonBoundingClientRect();
	const navHeight = (top - (statusBarHeight as number)) * 2 + height;

	return {
		statusBarHeight : statusBarHeight as number,
		statusBarHeightPx : `${statusBarHeight}px`,
		customHeaderHeight : navHeight + (statusBarHeight as number),
		customHeaderHeightPx :  `${navHeight + (statusBarHeight as number)}px`,
		navHeight,
		navHeightPx : `${navHeight}px`
	};
}

/**
 * 底部安全区域
 * @returns bottomSafeAreaHeiht:状态栏高度，statusBarHeightPx:状态栏高度带单位（px）
 * @returns navHeight:自定义导航栏高度，navHeightPx:自定义导航栏高度带单位（px）
 */
export function useBottomSafeArea () {
	const systemInfo = PD.UniHelp.getSystemInfo();
	
	return {
		bottomSafeAreaHeiht : systemInfo.safeArea?.bottom ? (systemInfo.screenHeight - systemInfo.safeArea.bottom) / 2 : 0,
		tabBarHeightPx : '50px',
	};
}